// 简单的URL转换测试脚本 - ES模块版本

// 模拟环境变量
process.env.VITE_APP_ENV = "production";
process.env.VITE_DICOM_SERVER_URL = "http://192.168.16.250:7002";

// 动态导入ES模块
async function testUrlConversion() {
	try {
		// 使用动态导入
		const { convertToProxyUrl, processDicomUrl } = await import(
			"./src/utils/dicomUrlHandler.js"
		);

		console.log("=== DICOM URL转换测试 ===\n");

		// 测试前置机返回的URL
		const testUrl =
			"http://192.168.0.8:7002/20251030/CR/251133842_2.25.101271155734966076315627005690963676856/2.25.101271155734966076315627005690963676856.1013.1.dcm";

		console.log("原始URL:", testUrl);

		// 测试convertToProxyUrl
		const convertedUrl = convertToProxyUrl(testUrl);
		console.log("转换后URL:", convertedUrl);

		// 测试processDicomUrl
		const processedUrl = processDicomUrl(testUrl);
		console.log("处理后URL:", processedUrl);

		// 验证转换是否正确
		const expectedPath =
			"/files/20251030/CR/251133842_2.25.101271155734966076315627005690963676856/2.25.101271155734966076315627005690963676856.1013.1.dcm";
		const isCorrect = convertedUrl === expectedPath;

		console.log("\n=== 验证结果 ===");
		console.log("期望路径:", expectedPath);
		console.log("实际路径:", convertedUrl);
		console.log("转换是否正确:", isCorrect ? "✓ 正确" : "✗ 错误");

		if (isCorrect) {
			console.log("\n✅ URL转换功能正常工作！");
			console.log(
				"前置机内网IP http://192.168.0.8:7002 已成功转换为网闸IP http://192.168.16.250:7002"
			);
		} else {
			console.log("\n❌ URL转换功能存在问题！");
		}
	} catch (error) {
		console.error("测试失败:", error);
	}
}

testUrlConversion();
